/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.room.maubinh;

import extension.maubinh.handler.MauBinhFlag;
import extension.maubinh.handler.MauBinhCommand;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import extension.game.room.GameResponse;
import java.util.LinkedList;
import java.util.List;
import log.Debug;

/**
 *
 * @author daz
 */
public class MauBinhResponse extends GameResponse {

    public MauBinhResponse(MauBinhExtension ext) {
        super(ext);
    }

    void sendDealCard(List<Integer> listCards, List<Integer> dealPos, boolean isRightOrder, User user) {
        ISFSObject resObj = new SFSObject();
        resObj.putIntArray(MauBinhFlag.LIST_CARD, listCards);
        resObj.putIntArray("deal_pos", dealPos);
        resObj.putBool("is_right_order", isRightOrder);
        ext.send(MauBinhCommand.DEAL_CARD, resObj, user);
    }

    void sendMatchFinish(List<Integer> havePhom, List<Integer> playerRank, List<Long> moneyResult, List<Long> playerMoney, int tableHost) {
        ISFSObject resObj = new SFSObject();
        resObj.putIntArray(MauBinhFlag.HAVE_PHOM, havePhom);
        resObj.putLongArray(MauBinhFlag.MONEY_RESULT, moneyResult);
        resObj.putIntArray(MauBinhFlag.PLAYER_RANK, playerRank);
        resObj.putLongArray(MauBinhFlag.PLAYER_MONEY, playerMoney);
        resObj.putInt(MauBinhFlag.TABLE_HOST, tableHost);
        ext.send(MauBinhCommand.FINISH_MATCH, resObj, ext.getParentRoom().getUserList());
        Debug.d(resObj.getDump());
    }

    void sendMoneyChange(long moneyChange, int playerWin, long playerWinMoney, int playerLost, long playerLostMoney) {
        ISFSObject resObj = new SFSObject();
        resObj.putLong(MauBinhFlag.MONEY_CHANGE, moneyChange);
        resObj.putInt(MauBinhFlag.PLAYER_WIN, playerWin);
        resObj.putLong(MauBinhFlag.PLAYER_WIN_MONEY, playerWinMoney);
        resObj.putInt(MauBinhFlag.PLAYER_LOST, playerLost);
        resObj.putLong(MauBinhFlag.PLAYER_LOST_MONEY, playerLostMoney);
        ext.send(MauBinhCommand.MONEY_CHANGE, resObj, ext.getParentRoom().getUserList());
    }

    void sendPlayerCard(MauBinhPlayer phomPlayer) {
        ISFSObject resObj = new SFSObject();
        resObj.putIntArray(MauBinhFlag.PLAYER_CARD, phomPlayer.getListCardIds());
        resObj.putInt(MauBinhFlag.PLAYER_POS, phomPlayer.getSeatPos());
        ext.send(MauBinhCommand.PLAYER_CARD, resObj, ext.getParentRoom().getUserList());
        log(resObj);
    }

    void sendUpdateTableHost(int newTableHost, int isPlay) {
        Debug.d("send update table host");
        ISFSObject resObj = new SFSObject();
        resObj.putInt(MauBinhFlag.TABLE_HOST, newTableHost);
        resObj.putInt(MauBinhFlag.IS_PLAY, isPlay);
        ext.send(MauBinhCommand.UPDATE_TABLE_HOST, resObj, ext.getParentRoom().getUserList());
    }

    void sendReadyPlay(int tableHost, long timeRemain) {
        ISFSObject resObj = new SFSObject();
        resObj.putInt(MauBinhFlag.TABLE_HOST, tableHost);
        resObj.putLong("time_remain", timeRemain);
        ext.send(MauBinhCommand.READY_PLAY, resObj, ext.getParentRoom().getUserList());
    }

    void sendResult(
            List<Long> branchResult1, List<Long> branchResult2, List<Long> branchResult3,
            long moneyResult1, long moneyResult2, long moneyResult3,
            List<Integer> listBranchType1, List<Integer> listBranchType2, List<Integer> listBranchType3,
            List<Long> listTotalResult,
            List<Integer> listCards,
            List<Integer> cardPos,
            User user) {
        ISFSObject resObj = new SFSObject();
        resObj.putLongArray("branch_result1", branchResult1);
        resObj.putLongArray("branch_result2", branchResult2);
        resObj.putLongArray("branch_result3", branchResult3);
        resObj.putLongArray("total_money_result", listTotalResult);
        resObj.putLong("money_result1", moneyResult1);
        resObj.putLong("money_result2", moneyResult2);
        resObj.putLong("money_result3", moneyResult3);
        resObj.putIntArray("list_cards", listCards);
        resObj.putIntArray("card_pos", cardPos);
        resObj.putIntArray("branch_type1", listBranchType1);
        resObj.putIntArray("branch_type2", listBranchType2);
        resObj.putIntArray("branch_type3", listBranchType3);

        ext.send(MauBinhCommand.MATCH_RESULT, resObj, user);
        Debug.d("send result");
    }

    public void sendExchangeResult(boolean rightOrder,
            List<Integer> cardHightLight1,
            List<Integer> cardHightLight2,
            List<Integer> cardHightLight3,
            int card_type1,
            int card_type2,
            int card_type3,
            User user) {
        ISFSObject resObj = new SFSObject();
        resObj.putBool("is_right_order", rightOrder);
        resObj.putIntArray("card_hight_light1", cardHightLight1);
        resObj.putIntArray("card_hight_light2", cardHightLight2);
        resObj.putIntArray("card_hight_light3", cardHightLight3);
        resObj.putInt("card_type1", card_type1);
        resObj.putInt("card_type2", card_type2);
        resObj.putInt("card_type3", card_type3);
        ext.send(MauBinhCommand.EXCHANGE_CARD, resObj, user);
    }
}
